package com.sl.hx.shop.ui.classify.presenter;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.sl.hx.shop.base.BasePresenter;
import com.sl.hx.shop.bean.GoodsClassify;
import com.sl.hx.shop.bean.SearchResult;
import com.sl.hx.shop.http.ApiFactory;
import com.sl.hx.shop.http.ApiRetrofit;
import com.sl.hx.shop.http.HttpUtil;
import com.sl.hx.shop.http.ProgressSubscribe;
import com.sl.hx.shop.ui.classify.contacts.ClassifyContacts;
import com.sl.hx.shop.ui.classify.contacts.SearchResultContacts;
import com.sl.hx.shop.utils.ScreenUtil;
import com.trello.rxlifecycle2.android.ActivityEvent;
import com.trello.rxlifecycle2.android.FragmentEvent;

import java.util.List;

import io.reactivex.Observable;

public class SearchResultPresenter extends BasePresenter<SearchResultContacts.view> implements SearchResultContacts.presenter {

    private Context mContext;


    public SearchResultPresenter(Context context) {
        this.mContext=context;

    }

    //搜索商品
    public void getSearch(String mSearchTitle, int sort, int page, int num) {
        Observable observable = ApiFactory.getInstance().getSearch(ApiRetrofit.getCacheControl(),mSearchTitle,sort,1,page,num);
        HttpUtil.getInstance().toSubscribe(observable, new ProgressSubscribe<List<SearchResult>>(mContext) {
            @Override
            protected void _onNext(List<SearchResult> searchResultList) {
                getView().ShowResultList(searchResultList);
            }
            @Override
            protected void _onError(String message) {
            }
        }, true,getView(), ActivityEvent.DESTROY);
    }



}
